package com.everflourish.yeah100.adapter;

import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.design.widget.TextInputLayout;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.everflourish.yeah100.R;
import com.everflourish.yeah100.act.markingsystem.MarkingMenuActivity;
import com.everflourish.yeah100.act.menu.FragmentExam;
import com.everflourish.yeah100.act.questionlib.QuestionListActivity;
import com.everflourish.yeah100.act.statistics.TeacherStatisticsActivity;
import com.everflourish.yeah100.act.test.ExpendActivity;
import com.everflourish.yeah100.entity.Examination;
import com.everflourish.yeah100.entity.ExaminationModel;
import com.everflourish.yeah100.entity.constant.SubjectEnum;
import com.everflourish.yeah100.ui.CircleView;
import com.everflourish.yeah100.ui.dialog.LoadDialog;
import com.everflourish.yeah100.utils.IntentUtil;
import com.everflourish.yeah100.utils.KeyBoardUtils;
import com.everflourish.yeah100.utils.LogUtil;
import com.everflourish.yeah100.utils.MyToast;
import com.everflourish.yeah100.utils.StringUtil;
import com.everflourish.yeah100.utils.Yeah100;
import com.everflourish.yeah100.utils.constant.Constant;
import com.everflourish.yeah100.utils.constant.ResultCode;
import com.everflourish.yeah100.utils.constant.RoleEnum;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.List;

/**
 * 作者：Created by Administrator on 2016/6/1.
 * 时间：2016/6/1
 */
public class ExaminationAdapter extends RecyclerView.Adapter<ExaminationAdapter.ExamViewHolder> {

    private Context mContext;
    private LayoutInflater mLayoutInflater;
    private List<ExaminationModel> mList;
    private FragmentExam mFragment;
    private LoadDialog mLoadDialog;
    private boolean isDeleting;
    public int checkStatus;

    public ExaminationAdapter(Context mContext, List<ExaminationModel> mList, FragmentExam fragmentExam) {
        this.mContext = mContext;
        this.mList = mList;
        this.mFragment = fragmentExam;
        mLayoutInflater = LayoutInflater.from(mContext);
    }

    @Override
    public ExamViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = mLayoutInflater.inflate(R.layout.item_examination, parent, false);
        ExamViewHolder viewHolder = new ExamViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(ExamViewHolder holder, final int position) {
        ExaminationModel examinationModel = mList.get(position);
        Examination examination = examinationModel.getExamination();
        final boolean isOperation = examinationModel.isOperation();
//        boolean isChecked = examinationModel.isChecked();
        holder.mExamNameTv.setText("考试名称：" + examinationModel.getExamination().getName());
        holder.mExamCreateTimeTv.setText("创建时间：" + examinationModel.getExamination().getDate());
        holder.mExamCreateNameTv.setText("创建人：" + examinationModel.getExamination().getSharer());

        String subject = examination.getSubject().trim();
        holder.mExamSubjectTv.setText(subject.substring(0, 1));
        if (subject.equals(SubjectEnum.CHINESE.subject)) {
            holder.mExamSubjectTv.setBackgroundColor(SubjectEnum.CHINESE.color);
        } else if (subject.equals(SubjectEnum.ENGLISH.subject)) {
            holder.mExamSubjectTv.setBackgroundColor(SubjectEnum.ENGLISH.color);
        } else if (subject.equals(SubjectEnum.MATH.subject)) {
            holder.mExamSubjectTv.setBackgroundColor(SubjectEnum.MATH.color);
        } else if (subject.equals(SubjectEnum.PHYSICS.subject)) {
            holder.mExamSubjectTv.setBackgroundColor(SubjectEnum.PHYSICS.color);
        } else if (subject.equals(SubjectEnum.POLITICS.subject)) {
            holder.mExamSubjectTv.setBackgroundColor(SubjectEnum.POLITICS.color);
        } else if (subject.equals(SubjectEnum.BIOLOGY.subject)) {
            holder.mExamSubjectTv.setBackgroundColor(SubjectEnum.BIOLOGY.color);
        } else if (subject.equals(SubjectEnum.HISTORY.subject)) {
            holder.mExamSubjectTv.setBackgroundColor(SubjectEnum.HISTORY.color);
        } else if (subject.equals(SubjectEnum.GEOGRAPHY.subject) || subject
                .equals(SubjectEnum.CHEMISTRY.subject)) {
            holder.mExamSubjectTv.setBackgroundColor(SubjectEnum.GEOGRAPHY.color);
        } else {
            holder.mExamSubjectTv.setBackgroundColor(SubjectEnum.OTHER.color);
        }
        if (isOperation) {
            holder.mOperationLl.setVisibility(View.VISIBLE);
        } else {
            holder.mOperationLl.setVisibility(View.GONE);
        }
        holder.mExamEditTv.setOnClickListener(new MyOnclickListener(holder, position));
        holder.mExamEmailTv.setOnClickListener(new MyOnclickListener(holder, position));
        holder.mExamMarkingTv.setOnClickListener(new MyOnclickListener(holder, position));
        holder.mExamQuestionTv.setOnClickListener(new MyOnclickListener(holder, position));
        holder.mExamReportTv.setOnClickListener(new MyOnclickListener(holder, position));
        holder.mExamItemCv.setOnClickListener(new MyOnclickListener(holder, position));
        holder.mExamItemCv.setOnLongClickListener(new MyOnLongClickListener(holder, position));
        holder.mExamQuestionTv.setOnClickListener(new MyOnclickListener(holder, position));
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    public class ExamViewHolder extends RecyclerView.ViewHolder {

        private CircleView mExamSubjectTv;  // 科目圆形
        private TextView mExamNameTv;  // 考试名称
        private TextView mExamCreateTimeTv;  // 考试创建时间
        private TextView mExamCreateNameTv;  // 考试创建人
        private TextView mExamEditTv;  // 考试修改
        private TextView mExamEmailTv;  // 发送邮件
        private TextView mExamMarkingTv;  // 阅卷
        private TextView mExamQuestionTv;  // 题目
        private TextView mExamReportTv;  // 报表
        private CardView mExamItemCv;  //  item
        private LinearLayout mOperationLl;  // 操作

        public ExamViewHolder(View itemView) {
            super(itemView);
            mExamItemCv = (CardView) itemView.findViewById(R.id.exam_item_cv);
            mExamSubjectTv = (CircleView) itemView.findViewById(R.id.subject_ct);
            mExamNameTv = (TextView) itemView.findViewById(R.id.item_exam_name);
            mExamCreateTimeTv = (TextView) itemView.findViewById(R.id.item_exam_time);
            mExamCreateNameTv = (TextView) itemView.findViewById(R.id.item_exam_creater);
            mExamEditTv = (TextView) itemView.findViewById(R.id.exam_edit_tv);
            mExamEmailTv = (TextView) itemView.findViewById(R.id.exam_email_tv);
            mExamMarkingTv = (TextView) itemView.findViewById(R.id.exam_marking_tv);
            mExamQuestionTv = (TextView) itemView.findViewById(R.id.exam_question_tv);
            mExamReportTv = (TextView) itemView.findViewById(R.id.exam_report_tv);
            mOperationLl = (LinearLayout) itemView.findViewById(R.id.exam_option_ll);
        }
    }

    class MyOnclickListener implements View.OnClickListener {

        private ExamViewHolder viewHolder;
        private int position;
        private Examination mExamination;

        public MyOnclickListener(ExamViewHolder viewHolder, int position) {
            this.viewHolder = viewHolder;
            this.position = position;
            mExamination = mList.get(position).getExamination();
        }

        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.exam_edit_tv:  // 修改
//                    Intent intent = new Intent(mFragment.mActivity,
//                            MarkingMenuActivity.class);

                    Intent intent = new Intent(mFragment.mActivity,
                            ExpendActivity.class);
                    intent.putExtra(IntentUtil.EXAMINATION, mExamination);
                    mFragment.getActivity().startActivityForResult(intent, 0x100);
                    break;
                case R.id.exam_email_tv:  //  邮件
                    if (Yeah100.mRoleEnum == RoleEnum.TEACHER
                            && mExamination.getStatisticTiggered().equals("Y")
                            && mExamination.getClasses() != null
                            && mExamination.getClasses().size() != 0) {
                        sendEmailForForm(mExamination);
                    } else if (Yeah100.mRoleEnum == RoleEnum.TEACHER
                            && mExamination.getStatisticTiggered().equals("N")) {
                        MyToast.showShort(mContext, "该考试还未统计");
                        return;
                    } else if (mExamination.getClasses() == null
                            || mExamination.getClasses().size() == 0) {
                        MyToast.showShort(mContext, "该考试没有考生");
                        return;
                    }
                    break;
                case R.id.exam_marking_tv:  //  阅卷
                    checkExaminationStatus(mExamination);
                    break;
                case R.id.exam_question_tv:  // 题库
                    Intent questionIntent = new Intent(mContext,
                            QuestionListActivity.class);
                    questionIntent.putExtra(IntentUtil.QUESTIONLIST, mExamination.getId());
                    mContext.startActivity(questionIntent);
                    break;
                case R.id.exam_report_tv:  // 报表
                    if (Yeah100.mRoleEnum == RoleEnum.TEACHER
                            && mExamination.getStatisticTiggered().equals("N")) {
                        statisticRequest(mExamination, position);
                    } else {
                        Intent statisticsIntent = new Intent(mContext,
                                TeacherStatisticsActivity.class);
                        statisticsIntent.putExtra(IntentUtil.EXAMINATION, mExamination);
                        mFragment.startActivityForResult(statisticsIntent, 120);
                    }
                    break;
                case R.id.exam_item_cv:  // item
                    boolean isOperation = mList.get(position).isOperation();
                    if (isOperation) {
                        mList.get(position).setIsOperation(!isOperation);
                    } else {
                        for (ExaminationModel model : mList) {
                            model.setIsOperation(false);
                        }
                        mList.get(position).setIsOperation(!isOperation);
                    }
                    notifyDataSetChanged();
                    break;
            }
        }
    }

    /**
     * 发送邮件对话框
     *
     * @param examination
     */
    private void sendEmailForForm(final Examination examination) {
        LayoutInflater inflater = LayoutInflater.from(mContext);
        LinearLayout updateNicknameLl = (LinearLayout) inflater.inflate(R.layout.dialog_setting_nickname, null);
        final TextInputLayout nickNameTil = (TextInputLayout) updateNicknameLl.findViewById(R.id.setting_nickname_update_til);
        final EditText nickNameEt = (EditText) updateNicknameLl.findViewById(R.id.setting_nickname_update_et);
        TextView nickNameTv = (TextView) updateNicknameLl.findViewById(R.id.setting_update_title);
        nickNameTv.setText("发送邮箱");
        nickNameTil.setHint("输入邮箱");
        if (TextUtils.isEmpty(Yeah100.loginInfo.userInfo.email)) {
            nickNameTv.setHint("输入邮箱");
        } else {
            nickNameEt.setText(Yeah100.loginInfo.userInfo.email);
            nickNameEt.setSelection(nickNameEt.getText().toString().length());
        }
        final AlertDialog dialog = new AlertDialog.Builder(mContext).setView(updateNicknameLl)
                .setPositiveButton("确定", null)
                .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        KeyBoardUtils.closeKeybord(nickNameEt, mContext);
                        dialog.dismiss();
                    }
                }).create();
        dialog.setCancelable(false);
        dialog.show();
        dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final String nickNameStr = nickNameEt.getText().toString();
                if (TextUtils.isEmpty(nickNameStr)) {
                    nickNameTil.setError("请输入新邮箱");
                    return;
                } else if (!StringUtil.isEmail(nickNameStr)) {
                    nickNameTil.setError("邮箱格式有误，请重新输入");
                    return;
                } else {
                    nickNameTil.setErrorEnabled(false);
                    nickNameTil.setError(null);
                }
                KeyBoardUtils.closeKeybord(nickNameEt, mContext);
                sendFormRequest(examination, nickNameStr);
                dialog.dismiss();
            }
        });
        KeyBoardUtils.openKeybord(nickNameEt, mContext);
    }

    class MyOnLongClickListener implements View.OnLongClickListener {

        private ExamViewHolder viewHolder;
        private int position;
        private ExaminationModel mExaminationModel;

        public MyOnLongClickListener(ExamViewHolder viewHolder, int position) {
            this.viewHolder = viewHolder;
            this.position = position;
            mExaminationModel = mList.get(position);
        }

        @Override
        public boolean onLongClick(View v) {
            switch (v.getId()) {
                case R.id.exam_item_cv:
                    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
                    builder.setMessage("确定要删除考试“" + mExaminationModel.getExamination().getName() + "”？");
                    builder.setPositiveButton("删除", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                            deleteExaminationRequest(mExaminationModel);
                        }
                    });
                    builder.setNegativeButton("否", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    });
                    builder.show();
                    return true;
            }
            return false;
        }
    }

    /**
     * 发送邮件请求
     *
     * @param examination
     * @param email
     */
    private void sendFormRequest(Examination examination, String email) {
        mLoadDialog = LoadDialog.show(mContext, null, "发送邮件中...", false);
        JsonObjectRequest request = mFragment.mRequest
                .exportExaminationRequest(examination.getId(), email,
                        new Response.Listener<JSONObject>() {
                            @Override
                            public void onResponse(JSONObject jsonObject) {
                                exportFormListener(jsonObject);
                            }
                        }, new Response.ErrorListener() {
                            @Override
                            public void onErrorResponse(VolleyError volleyError) {
                                mFragment.mRequest.disposeError(mContext, mLoadDialog, volleyError, "发送邮件失败");
                            }
                        });
        mFragment.mQueue.add(request);
    }

    /**
     * 检查考试状态请求
     *
     * @param examination
     */
    private void checkExaminationStatus(final Examination examination) {
        mLoadDialog = LoadDialog.show(mContext, null, "加载中...", mFragment.mQueue);
        JsonObjectRequest request = mFragment.mRequest.checkExaminationStatus(examination.getId(),
                new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject jsonObject) {
                        checkExaminationListener(jsonObject, examination);
                    }
                }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError volleyError) {
                        LogUtil.e("查看考试失败", volleyError);
                        mFragment.mRequest.disposeError(mContext, mLoadDialog, volleyError, "查看考试失败");
                    }
                });
        mFragment.mQueue.add(request);
    }

    /**
     * 删除考试请求
     *
     * @param examinationModel
     */
    private void deleteExaminationRequest(final ExaminationModel examinationModel) {
        mLoadDialog = LoadDialog.show(mContext, null, "正在删除...", false);
        JsonObjectRequest request = mFragment.mRequest.deleteExaminationRequest(examinationModel.getExamination().getId(),
                new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject response) {
                        deleteExaminationListener(response, examinationModel);
                    }
                }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError volleyError) {
                        mFragment.mRequest.disposeError(mContext, mLoadDialog, volleyError, "删除考试失败");
                    }
                });
        mFragment.mQueue.add(request);
    }

    /**
     * 发送邮件监听
     *
     * @param response
     */
    private void exportFormListener(JSONObject response) {
        String resultCode = "";
        try {
            resultCode = response.getString(Constant.RESULT_CODE);
            if (resultCode.equals(ResultCode.result_ok.resultCode)) {
                MyToast.showShort(mContext, "发送邮件成功");
            } else if (resultCode
                    .equals(ResultCode.result_system_exception_999999E.resultCode)) {
                MyToast.showLong(mContext, R.string.readcard_071499_999999E);
            } else {
                MyToast.showShort(mContext, "发送邮件失败");
            }
        } catch (JSONException e) {
            LogUtil.e("JSON异常", e);
            MyToast.showShort(mContext, "发送邮件失败");
        } finally {
            LoadDialog.dismiss(mLoadDialog);
        }
    }

    /**
     * 检查考试状态监听
     *
     * @param response
     * @param examination
     */
    private void checkExaminationListener(JSONObject response, Examination examination) {
        String resultCode = "";
        try {
            resultCode = response.getString(Constant.RESULT_CODE);
            if (resultCode.equals(ResultCode.result_ok.resultCode)) {
                checkStatus = response.getInt("flag");
                Intent intent = new Intent(mFragment.mActivity,
                        MarkingMenuActivity.class);
                intent.putExtra(IntentUtil.EXAMINATION, examination);
                intent.putExtra("flag", checkStatus);
                mFragment.startActivityForResult(intent, 0x100);
            } else {
                if (resultCode.equals(ResultCode.result_000001E.resultCode)) {
                    MyToast.showLong(mContext,
                            R.string.examination_08262_000001E);
                } else if (resultCode
                        .equals(ResultCode.result_300001E.resultCode)) {
                    MyToast.showLong(mContext,
                            R.string.examination_08263_300001E);
                } else if (resultCode
                        .equals(ResultCode.result_000012E.resultCode)) {
                    MyToast.showLong(mContext,
                            R.string.examination_08261_000012E);
                } else if (resultCode
                        .equals(ResultCode.result_system_exception_999999E.resultCode)) {
                    MyToast.showLong(mContext,
                            R.string.examination_082699_999999E);
                } else {
                    MyToast.showLong(mContext, "查看考试失败");
                }
            }
        } catch (Exception e) {
            LogUtil.e("JSON异常", e);
            MyToast.showLong(mContext, "查看考试失败");
        } finally {
            LoadDialog.dismiss(mLoadDialog);
        }
    }

    /**
     * 删除考试监听
     *
     * @param response
     */
    private void deleteExaminationListener(JSONObject response, ExaminationModel model) {
        String resultCode = "";
        try {
            resultCode = response.getString(Constant.RESULT_CODE);
            if (resultCode.equals(ResultCode.result_ok.resultCode)) {
                MyToast.showShort(mContext, "删除考试成功");
                mList.remove(model);
                notifyDataSetChanged();
                if (mList.size() == 0) {
                    mFragment.mEmptyTv.setVisibility(View.VISIBLE);
                } else {
                    mFragment.mEmptyTv.setVisibility(View.GONE);
                }
            } else {
                if (Yeah100.mRoleEnum == RoleEnum.TEACHER) {
                    if (resultCode.equals(ResultCode.result_000001E.resultCode)) {
                        MyToast.showShort(mContext,
                                R.string.examination_08201_000001E);
                    } else if (resultCode
                            .equals(ResultCode.result_300001E.resultCode)) {
                        MyToast.showShort(mContext,
                                R.string.examination_08202_300001E);
                    } else if (resultCode
                            .equals(ResultCode.result_000012E.resultCode)) {
                        MyToast.showShort(mContext,
                                R.string.examination_08203_000012E);
                    } else if (resultCode
                            .equals(ResultCode.result_system_exception_999999E.resultCode)) {
                        MyToast.showShort(mContext,
                                R.string.examination_082099_999999E);
                    } else {
                        MyToast.showShort(mContext, "删除考试失败");
                    }
                }
            }
        } catch (JSONException e) {
            LogUtil.e("JSON异常", e);
            MyToast.showShort(mContext, "删除考试失败");
        } finally {
            LoadDialog.dismiss(mLoadDialog);
        }
    }

    /**
     * 统计成绩请求
     *
     * @param examination
     */
    public void statisticRequest(final Examination examination, final int position) {
        mLoadDialog = LoadDialog.show(mContext, null, "正在统计中...", mFragment.mQueue);
        JsonObjectRequest request = mFragment.mRequest
                .executeStatisticJob(examination.getId(),
                        new Response.Listener<JSONObject>() {
                            @Override
                            public void onResponse(JSONObject response) {
                                statisticListener(response, examination, position);
                            }
                        }, new Response.ErrorListener() {
                            @Override
                            public void onErrorResponse(VolleyError error) {
                                mFragment.mRequest.disposeError(mContext, mLoadDialog, error, "统计学生成绩失败");
                            }
                        });
        mFragment.mQueue.add(request);
    }

    /**
     * 发布考试请求
     *
     * @param examination
     */
    private void publishRequest(final Examination examination, final int position) {
        // 发布考试
        JsonObjectRequest request = mFragment.mRequest
                .publishExaminationRequest(examination.getId(),
                        new Response.Listener<JSONObject>() {
                            @Override
                            public void onResponse(JSONObject jsonObject) {
                                publishListener(jsonObject, position);
                            }
                        }, new Response.ErrorListener() {
                            @Override
                            public void onErrorResponse(VolleyError volleyError) {
                                LogUtil.e("发布考试发生异常", volleyError);
                                mFragment.mRequest.disposeError(mContext, mLoadDialog, volleyError, "统计学生成绩失败");
                            }
                        });
        mFragment.mQueue.add(request);
    }

    /**
     * 统计成绩监听
     *
     * @param response
     */
    private void statisticListener(JSONObject response, Examination examination, int position) {
        String resultCode = "";
        try {
            resultCode = response.getString(Constant.RESULT_CODE);
            if (resultCode.equals(ResultCode.result_ok.resultCode)) {
                publishRequest(examination, position);
            } else if (resultCode.equals(ResultCode.result_000012E.resultCode)) {
                MyToast.showShort(mContext, R.string.readcard_07092_000012E);
            } else if (resultCode.equals(ResultCode.result_000001E.resultCode)) {
                MyToast.showShort(mContext, R.string.readcard_07091_000001E);
            } else if (resultCode.equals(ResultCode.result_300001E.resultCode)) {
                MyToast.showShort(mContext, R.string.readcard_07093_300001E);
            } else if (resultCode.equals(ResultCode.result_300020E.resultCode)) {
                String errorMsg = response.getString("errorMessage");
                MyToast.showShort(mContext, errorMsg);
            } else if (resultCode
                    .equals(ResultCode.result_system_exception_999999E.resultCode)) {
                MyToast.showShort(mContext, R.string.readcard_070999_999999E);
            } else {
                MyToast.showShort(mContext, "统计学生成绩失败");
            }
        } catch (JSONException e) {
            LogUtil.e("JSON异常", e);
            e.printStackTrace();
        } finally {
            if (!resultCode.equals(ResultCode.result_ok.resultCode)) {
                LoadDialog.dismiss(mLoadDialog);
            }
        }
    }

    /**
     * 发布考试监听
     *
     * @param response
     * @param position
     */
    private void publishListener(JSONObject response, int position) {
        String resultCode = "";
        try {
            resultCode = response.getString(Constant.RESULT_CODE);
            if (resultCode.equals(ResultCode.result_ok.resultCode)) {
                mList.get(position).getExamination().setStatisticTiggered("Y");
                mList.get(position).getExamination().setStatus("1");
                Intent intent = new Intent(mContext,
                        TeacherStatisticsActivity.class);
                intent.putExtra(IntentUtil.EXAMINATION, mList.get(position).getExamination());
                mFragment.startActivityForResult(intent, 100);
                MyToast.showShort(mContext, "统计成绩成功");
            } else if (resultCode.equals(ResultCode.result_000001E.resultCode)) {
                MyToast.showLong(mContext, R.string.readcard_07101_000001E);
            } else if (resultCode.equals(ResultCode.result_300001E.resultCode)) {
                MyToast.showLong(mContext, R.string.readcard_07102_300001E);
            } else if (resultCode.equals(ResultCode.result_000012E.resultCode)) {
                MyToast.showLong(mContext, R.string.readcard_07103_000012E);
            } else if (resultCode.equals(ResultCode.result_300015E.resultCode)) {
                MyToast.showLong(mContext, R.string.readcard_07104_300015E);
            } else if (resultCode
                    .equals(ResultCode.result_system_exception_999999E.resultCode)) {
                MyToast.showLong(mContext, R.string.readcard_071099_999999E);
            } else {
                MyToast.showLong(mContext, "统计成绩失败");
            }
        } catch (JSONException e) {
            LogUtil.e("JSON异常", e);
            MyToast.showLong(mContext, "统计成绩失败");
        } finally {
            LoadDialog.dismiss(mLoadDialog);
        }
    }

}